package day2.线程池.demo3;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test {
public static void main(String[] args) {
    Myfactory myfactory= new Myfactory();
    ThreadPoolExecutor pool = new ThreadPoolExecutor(
            2,
            4,
            4,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(3),
            myfactory,
            new ThreadPoolExecutor.DiscardOldestPolicy()
    );

    for (int i = 1; i <= 20; i++) {
        System.out.println("添加任务："+i);
        pool.execute(new MyTask(i));
    }

}
}
class a{
    public void b(){

    }
}
